"""
pymysql 执行建表语句
"""
from pymysql import Connection

# 创建数据库连接对象
conn = Connection(
    host='localhost',
    port=3306,
    user='root',
    passwd='root',
    database='db04',
)

# 创建游标对象
cursor = conn.cursor()

# 定义SQL语言
sql = """
    create table if not exists student(
        id int primary key auto_increment,
        name varchar(20),
        age int,
        gender varchar(20),
        address varchar(20)
    )
"""
# 执行SQL
cursor.execute(sql)

# 释放资源
cursor.close()
conn.close()